package writer_;

import java.io.*;

/**
 * @author DCSGO
 * @version 1.0
 * 模拟拷贝文本文件
 * 万不可用字符流操作 二进制文件(视频、音频、图片......)
 */
public class BufferedCopy {
    public static void main(String[] args) {
        String srcFilePath = "D:\\src\\stream.txt";
        String destFilePath = "E:\\dest\\stream.Copy.txt";
        BufferedReader br = null;
        BufferedWriter bw = null;
        try {
            br = new BufferedReader(new FileReader(srcFilePath));
            bw = new BufferedWriter(new FileWriter(destFilePath));
            String line;
            while ((line = br.readLine()) != null) {
                bw.write(line);
                bw.newLine();
            }
            System.out.println("拷贝完成");
        } catch (IOException e) {
            e.getStackTrace();
        } finally {
            try {
                if (br != null) {
                    br.close();
                }
                if (bw != null) {
                    bw.close();
                }
            } catch (IOException e) {
                e.getStackTrace();
            }
        }
    }
}
